package com.huosu.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.huosu.commons.constant.DataType;
import com.huosu.commons.constant.ParamType;
import com.huosu.commons.constant.Produces;
import com.huosu.commons.response.ApiResult;
import com.huosu.domain.ClassVideo;
import com.huosu.domain.miner.*;
import com.huosu.service.IComputeService;
import com.huosu.service.IMinerService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * <p>
 * 课程视频控制器
 * </p>
 *
 * @author zhangjian
 * @since 2019-12-12
 */
@RestController
@Api(tags = "小程序接口")
@RequestMapping("/v1/byxcApi")
public class MinerController {

	@Autowired
	private IMinerService service;

	@Autowired
	private IComputeService iComputeService;

	@ApiOperation(value = "课程视频列表", notes = "课程视频列表")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "pageCurrent", value = "页码", dataType = DataType.INT, paramType = ParamType.PATH, required = true, defaultValue = "1"),
			@ApiImplicitParam(name = "pageSize", value = "每页显示条数", dataType = DataType.INT, paramType = ParamType.PATH, required = true, defaultValue = "10")
	})
	@PostMapping(value = "/getVideoPage/{pageCurrent}/{pageSize}", produces = Produces.APPLICATION_JSON)
	public ApiResult<IPage<ClassVideo>> selectPage(@PathVariable Integer pageCurrent, @PathVariable Integer pageSize, @RequestBody @ApiParam(value = "查询条件") MinerQuery query) {
		return ApiResult.ok(service.selectPage(pageCurrent, pageSize, query));
	}

	@ApiOperation(value = "课程计算器列表", notes = "课程计算器列表")
	@PostMapping(value = "/getClassCompute", produces = Produces.APPLICATION_JSON)
	public ApiResult<List<ClassCompute>> getClassCompute() {
		return ApiResult.ok(iComputeService.getClassCompute());
	}

	@ApiOperation(value = "课程优惠规则", notes = "课程优惠规则")
	@PostMapping(value = "/getClassComputeRule", produces = Produces.APPLICATION_JSON)
	public ApiResult<List<ComputeRule>> getClassComputeRule() {
		return ApiResult.ok(iComputeService.getClassComputeRule());
	}

}
